package com.bestflashsolutions.components
{
	public class DJStringUtil
	{
		public function DJStringUtil()
		{
		}
		
		public static function unescapeHTML(string:String):String {
			string = string.replace(/[\r\n]/g, "<br>");
			string = string.replace(/\\\\/g, "\\")
			string = string.replace(/&lts;/g, "<");
			string = string.replace(/&gts;/g, ">"); 
			string = string.replace(/&quots;/g, '"');
			string = string.replace(/&amps;/g, "&");
			
			return string;		
		}
			
		//if we use the literal regexp notation, flex gets confused and thinks the quote starts a string
		private static var quoteregex:RegExp = new RegExp('"', "g");
		
		public static function escapeHTML(string:String):String {
			string = string.replace(/<br>/g, "\n");
			string = string.replace(/&/g, "&amps;");
			string = string.replace(/</g, "&lts;");
			string = string.replace(/>/g, "&gts;");
			string = string.replace(quoteregex, "&quots;");
			//	string = string.replace(/\\/g, "\\\\");
			return string;			
		}
		
	}
}